﻿using Architecture.Api.Application.Command.RoleCommand;
using Architecture.Domain.RBAC;
using Architecture.Service;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.RoleHandler
{
    public class RoleBackfillCommandHandler : IRequestHandler<RoleBackfillCommand, Role>
    {
        private readonly IRoleService _roleService;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="roleService"></param>
        public RoleBackfillCommandHandler(IRoleService roleService)
        {
            _roleService = roleService;
        }

        public async Task<Role> Handle(RoleBackfillCommand request, CancellationToken cancellationToken)
        {
            return await _roleService.GetByIdAsync( request.RoleId );
        }
    }
}
